using System.Data;

namespace xiushen.Domain
{
    public partial class Entities : IObjectContext
    {
        public System.Data.Common.DbTransaction Transaction { get; set; }

        public System.Data.Common.DbTransaction BeginTransaction(System.Data.IsolationLevel isolationLevel)
        {
            if (Connection.State != ConnectionState.Open)
            {
                Connection.Open();
            }

            Transaction = Connection.BeginTransaction(isolationLevel);

            return Transaction;
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            Transaction = null;
        }
    }
}